<?php
/*
 * CRMJqueryUiTabWidget File
 *
 * @link http://riedel-st.de
 * @author Stefan Riedel <sr@riedel-st.de>
 */

/**
 * the tab content parser
 *
 * @author Stefan Riedel
 */
class CRMJqueryUiTabWidget extends CRMJqueryUiBase {
    
    protected $_title;
    
    protected $_body;

    public function getTitle() {
        return $this->_title;
    }

    public function setTitle($title) {
        $this->_title = (string)$title;
    }

    public function init() {
        ob_start();
    }

    public function run() {
        if(empty($this->_body)) {
            $this->_body = ob_get_contents();
            ob_end_clean();
        } else {
            ob_end_flush();
        }

        list($name, $id) = $this->resolveNameID();
        echo $this->_htmlCode($id);
    }

    protected function _htmlCode($id) {
        return CHtml::tag('div', array('id'=>$id, 'title'=>$this->getTitle()), $this->_body);
    }
}
?>
